home *** CD-ROM | disk | FTP | other *** search
Text File | 1996-08-24 | 1.6 KB | 77 lines | [TEXT/CWIE] |
- unit MyScan;
-
- interface
-
- *** moved to MyFileSystemUtils ***
-
- uses
- Files;
-
- type
- ScanProc = function(var fs:FSSpec; folder:boolean; path:Str255; var pb:CInfoPBRec):boolean;
- { for folders, return true to scan contents }
- { for files return true if you delete the file - other changes to the file system would be bad... }
-
- function ScanDirectory (fs: FSSpec; doit: ScanProc): OSErr;
-
- implementation
-
- uses
- MyFileSystemUtils;
-
- function ScanDirectory (fs: FSSpec; doit: ScanProc): OSErr;
- var
- pb: CInfoPBRec;
- ret, folder: boolean;
- path: Str255;
- procedure Scan (dirID: longint);
- var
- index, len: integer;
- oe: OSErr;
- begin
- index := 1;
- repeat
- with pb do begin
- oe := MyGetCatInfo(fs.vRefNum, dirID, fs.name, index, pb);
- index := index + 1;
- if oe = noErr then begin
- fs.parID := dirID;
- folder := BAND(pb.ioFlAttrib, ioDirMask) <> 0;
- ret := doit(fs, folder, path, pb);
- if folder and ret then begin
- len := length(path);
- path := concat(path, fs.name, ':');
- Scan(pb.ioDirID);
- path[0] := chr(len);
- end
- else if not folder and ret then begin
- index := index - 1;
- end;
- end;
- end;
- until oe <> noErr;
- end;
- var
- err: OSErr;
- dummy: boolean;
- begin
- path := ':';
- if fs.name <> '' then begin
- err := MyGetCatInfo(fs.vRefNum, fs.parID, fs.name, 0, pb);
- if err = noErr then begin
- if BAND(pb.ioFlAttrib, ioDirMask) <> 0 then begin
- Scan(pb.ioDirID);
- end
- else begin
- dummy := doit(fs, false, path, pb);
- end;
- end;
- end
- else begin
- Scan(fs.parID);
- err := noErr;
- end;
- ScanDirectory := err;
- end;
-
- end.